<template>
  <div class="jian-jie-page">
    <div class="jian-jie">
      <div class="introduction">
        <div class="left">
          <div class="title"><span>公司信息</span></div>
          <div :class="{ xinxi: info?.intro && info?.intro.length > 130 }" class="max-height" ref="infoRef">
            <span>{{ info?.intro }}</span>
          </div>
          <div class="btn" v-if="info?.intro && info?.intro.length > 130">
            <a-button @click="onExpand"
              ><span class="moreContent">查看全部内容</span
              ><down-outlined style="color: #666" v-if="!expandInfo.jianjie" /><up-outlined style="color: #666" v-else
            /></a-button>
          </div>

          <div class="border"></div>

          <!-- 公司优势 -->
          <div class="advantage">
            <div class="title">
              <span>公司优势</span>
            </div>
            <div class="tag-box">
              <div class="tag" v-for="(item, index) in info?.feature" :key="index">
                {{ item }}
              </div>
            </div>
            <div class="border"></div>
          </div>

          <!-- 工商信息 -->
          <div class="gong-shang-xin-xi">
            <div class="title">
              <span>工商信息</span>
            </div>
            <div style="margin-left: 30px">
              <a-row class="mb-28 ml-6" :gutter="10">
                <a-col :span="8">
                  <div class="top-text">企业信息</div>
                  <div class="bottom-text">{{ info?.name }}</div>
                </a-col>
                <a-col :span="8">
                  <div class="top-text">法定代表人</div>
                  <div class="bottom-text">{{ info?.legalPerson }}</div>
                </a-col>
                <a-col :span="8">
                  <div class="top-text">成立时间</div>
                  <div class="bottom-text">{{ info?.establishTime }}</div>
                </a-col>
              </a-row>

              <a-row class="mb-20 ml-6" :gutter="10">
                <a-col :span="8">
                  <div class="top-text">企业类型</div>
                  <div class="bottom-text">{{ info?.typeCodeName }}</div>
                </a-col>
                <a-col :span="8">
                  <div class="top-text">经营状态</div>
                  <div class="bottom-text">{{ info?.statusName }}</div>
                </a-col>
                <a-col :span="8">
                  <div class="top-text">注册资本</div>
                  <div class="bottom-text">{{ info?.registeredCapital }}万元</div>
                </a-col>
              </a-row>
              <a-row class="mb-28 ml-6" :gutter="10" v-if="expandInfo.gongshangxinxi">
                <a-col :span="8">
                  <div class="top-text">统一信用代码</div>
                  <div class="bottom-text">{{ info?.unifiedCreditCode }}</div>
                </a-col>
              </a-row>
              <a-row class="mb-28 ml-6" :gutter="10" v-if="expandInfo.gongshangxinxi">
                <a-col>
                  <div class="top-text">经营范围</div>
                  <div class="bottom-text">{{ info?.businessNature }}</div>
                </a-col>
              </a-row>
            </div>

            <div class="btn">
              <a-button @click="onExpand2"
                >查看全部内容<down-outlined v-if="!expandInfo.gongshangxinxi" /><up-outlined v-else
              /></a-button>
            </div>
          </div>
        </div>
        <div class="right">
          <div class="di-dian">
            <div class="title">
              <span>公司地点</span>
            </div>
            <div class="content">
              <div class="addr">
                <img src="../../assets/images/address@2x.png" class="w-13px h-17px mr-4px" alt="" />
                <span> {{ info?.address }}</span>
              </div>
              <div class="map" ref="mapRef"></div>
            </div>
          </div>
        </div>
      </div>
      <div class="recruitPosition">
        <div class="top">
          <div class="title">
            <span>在招职位</span>
          </div>
          <div class="more" @click="emit('change', '2')">
            查看更多
            <RightOutlined />
          </div>
        </div>
        <div>
          <ZaiZhaoZhiWei />
        </div>
      </div>

      <!-- 招聘职位 -->
      <div class="zhao-pin-zhi-wei" v-if="jobs?.length">
        <div class="title">在招职位</div>
        <div class="more-action" @click="emit('change', '2')">
          查看更多
          <RightOutlined />
        </div>
        <div class="content">
          <ul>
            <li v-for="item in jobs" :key="item.id">
              <Item :data="item" />
            </li>
          </ul>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { computed, reactive, ref, onMounted, onUnmounted, watch } from 'vue';
import Item from './Item.vue';
import ZaiZhaoZhiWei from './ZaiZhaoZhiWei.vue';
import { RightOutlined, UpOutlined, DownOutlined } from '@ant-design/icons-vue';

const emit = defineEmits(['change']);
const props = defineProps(['info']);
const infoRef = ref();
const mapRef = ref();
const mapInstance = ref();
const expandInfo = reactive({
  jianjie: false,
  gongshangxinxi: false,
});

// const envImages = computed(() => {
//   const companyEnvImageList = props.info?.companyEnvImageList || [];
//   const companyGateImageList = props.info?.companyGateImageList || [];
//   return [...companyGateImageList, ...companyEnvImageList];
// });

// const imgs = computed(() => {
//   return props.info?.companyEnvImageList || [];
// });

const jobs = computed(() => {
  return props.info?.jobInfoBos || [];
});

// 简介展开收起
function onExpand() {
  const classNames = infoRef.value.classList;
  if (classNames.contains('max-height')) {
    infoRef.value.classList.remove('max-height');
    infoRef.value.classList.add('xinxi');
  } else if (classNames.contains('xinxi')) {
    infoRef.value.classList.remove('xinxi');
    infoRef.value.classList.add('max-height');
  }
  expandInfo.jianjie = !expandInfo.jianjie;
}

function initMap(lat: number, lng: number) {
  const TMap = (window as any).TMap;
  const container = mapRef.value;
  const center = new TMap.LatLng(lat, lng);

  mapInstance.value = new TMap.Map(container, {
    center: center,
    zoom: 11, //设置地图缩放级别
    viewMode: '2D',
    showControl: false,
  });

  const markerLayer = new TMap.MultiMarker({
    id: +new Date(),
    map: mapInstance.value,
  });
  markerLayer.add({ position: center });
}

// 展开收起企业工商信息
function onExpand2() {
  expandInfo.gongshangxinxi = !expandInfo.gongshangxinxi;
}

onMounted(() => {
  // onExpand();
  watch(
    () => props.info,
    (newVal, oldVal) => {
      if (newVal !== undefined) {
        initMap(newVal.latitude, newVal.longitude);
      }
    },
    {
      immediate: true,
    },
  );
});

onUnmounted(() => {
  if (mapInstance.value) {
    mapInstance.value.destroy();
  }
});
</script>

<style lang="scss" scoped>
@mixin title-box {
  font-size: 16px;
  font-weight: 700;
  color: #333333;
  line-height: 16px;
  position: relative;
  padding-left: 8px;
  span {
    position: relative;
    z-index: 2;
  }
  &::before {
    position: absolute;
    content: '';
    display: block;
    width: 31px;
    height: 31px;
    background: url(../../assets/images/company-title@2x.png) no-repeat;
    background-size: cover;
    left: 0px;
    top: -7px;
  }
}

ul,
li {
  list-style: none;
  padding: 0;
  margin: 0;
}

.jian-jie-page {
  min-height: 1000px;
}

.jian-jie {
  width: 100%;

  .introduction {
    position: relative;
    display: flex;
    box-sizing: border-box;
    padding: 27px 20px 28px 20px;
    background-color: #fff;
    border-radius: 0 0 8px 8px;
    .left {
      width: 804px;
    }

    .right {
      width: 316px;
      box-sizing: border-box;
      margin-left: 40px;
    }

    .title {
      @include title-box();
    }

    .xinxi {
      margin: 20px 0 0 30px;
      width: 774px;
      word-wrap: break-word;
      span {
        color: #999;
      }
    }
    .max-height {
      margin: 20px 0 0 30px;
      width: 774px;
      word-wrap: break-word;
      height: 45px;
      overflow: hidden;
      span {
        color: #999;
      }
    }
    .btn {
      margin-top: 20px;
      :deep(.ant-btn) {
        background: #ecf1fe;
        width: 805px;
        border: none;
        font-size: 13px;
        font-family:
          PingFangSC-Regular,
          PingFang SC;
        font-weight: 400;
        color: #3778ea;
      }

      i {
        margin-left: 4px;
        font-size: 14px;
        color: #3778ea;
      }
    }

    .mb-28 {
      margin-bottom: 20px;
    }

    .mb-20 {
      margin-bottom: 20px;
    }

    .ml-6 {
      margin-left: 7px;
    }

    .border {
      height: 1px;
      border: 1px solid #e5e5e5;
      margin-top: 28px;
      transform: scaleY(0.1);
    }
    .moreContent {
      width: 72px;
      height: 12px;
      font-size: 13px;
      font-family:
        PingFangSC-Regular,
        PingFang SC;
      font-weight: 400;
      color: #666666;
      line-height: 12px;
    }
    .advantage {
      margin-top: 30px;
      box-sizing: border-box;

      .title {
        margin-bottom: 20px;
      }

      .tag-box {
        margin: -4px;
        display: flex;
        margin-left: 30px;
        flex-wrap: wrap;

        .tag {
          height: 24px;
          border-radius: 2px;
          line-height: 24px;
          font-family:
            PingFangSC-Regular,
            PingFang SC;
          font-weight: 400;
          color: #999;
        }
      }
    }
  }

  .recruitPosition {
    background-color: white;
    padding: 20px 0px 28px 20px;
    margin-top: 20px;
    border-radius: 8px;
    .top {
      display: flex;
      justify-content: space-between;

      .more {
        font-size: 12px;
        font-family: 苹方-简 常规体;
        font-weight: 500;
        color: #666666;
        line-height: 12px;
        position: relative;
        padding-left: 8px;
        cursor: pointer;
        margin-right: 35px;
      }
    }

    .title {
      @include title-box();
    }
  }

  // 工商信息
  .gong-shang-xin-xi {
    // height: 256px;
    .title {
      margin-top: 27px;
      margin-bottom: 28px;
    }

    .top-text {
      font-size: 14px;
      font-family:
        PingFangSC-Regular,
        PingFang SC;
      font-weight: 400;
      color: #666666;
      line-height: 14px;
      margin-bottom: 12px;
    }

    .bottom-text {
      font-size: 14px;
      font-family:
        PingFangSC-Regular,
        PingFang SC;
      font-weight: 400;
      color: #222222;
      line-height: 14px;
      line-height: 22px;
    }

    // .xinxis {
    //   .enterprise {
    //     font-size: 14px;

    //     span:nth-child(1) {
    //       color: #999;
    //     }
    //     span:nth-child(3) {
    //       color: #222;
    //       padding-top: 10px;
    //       float: left;
    //     }
    //   }
    //   .enterprise:nth-child(1) {
    //     margin: 70px 0 0 30px;
    //     position: absolute;
    //   }
    //   .enterprise:nth-child(2) {
    //     margin: 70px 0 0 340px;
    //     position: absolute;
    //   }
    //   .enterprise:nth-child(3) {
    //     margin: 70px 0 0 598px;
    //     position: absolute;
    //   }
    //   .enterprise:nth-child(4) {
    //     margin: 140px 0 0 30px;
    //     position: absolute;
    //   }
    //   .enterprise:nth-child(5) {
    //     margin: 140px 0 0 340px;
    //     position: absolute;
    //   }
    //   .enterprise:nth-child(6) {
    //     margin: 140px 0 0 598px;
    //     position: absolute;
    //   }
    //   .enterprise:nth-child(7) {
    //     margin: 210px 0 0 30px;
    //     position: absolute;
    //   }
    //   .enterprise:nth-child(8) {
    //     margin: 210px 0 0 340px;
    //     position: absolute;
    //   }
    //   .enterprise:nth-child(9) {
    //     margin: 210px 0 0 598px;
    //     position: absolute;
    //   }
    // }
    // .btns {
    //   .geng {
    //     position: absolute;
    //     width: 784px;
    //     background: #ecf1fe;
    //     margin: 210px 0 0 20px;
    //   }
    // }
  }

  .environment {
    width: 100%;
    margin-bottom: 20px;
    .title {
      margin-bottom: 20px;
    }

    .content {
      width: 100%;
      box-sizing: border-box;
      border-radius: 8px;
      overflow: hidden;
      :deep(.ant-carousel .slick-dots li) {
        background-color: #c2d2f7;
        opacity: 0.9;
        border-radius: 8px;
      }
      :deep(.ant-carousel .slick-dots li button) {
        background-color: #1890ff;
        box-shadow: 0px 1px 3px 0px rgb(151 170 216 / 66%);
      }
    }
  }

  .di-dian {
    .content {
      box-sizing: border-box;
      margin-top: 24px;
      border-radius: 8px;
      overflow: hidden;
      .addr {
        margin-bottom: 13px;
        color: #666666;
        font-size: 14px;
        font-weight: 400;
        line-height: 24px;
      }
    }

    .map {
      width: 316px;
      height: 160px;
      border-radius: 8px;
      overflow: hidden;
    }
  }

  .address {
    position: absolute;
    top: 310px;
    left: 844px;

    .biao {
      span:nth-child(1) {
        width: 2px;
        height: 12px;
        background: #1890ff;
      }

      span:nth-child(2) {
        font-size: 16px;
        color: #222222;
        font-weight: 600;
      }
    }
  }

  .bottom {
    position: relative;
    margin-top: 46px;
    width: 1200px;
    height: 300px;
    background: #ffffff;
    border-radius: 8px;
    backdrop-filter: blur(0px);

    .biao {
      span:nth-child(1) {
        position: absolute;
        margin: 30px 0 0 20px;
        width: 2px;
        height: 12px;
        background: #1890ff;
      }

      span:nth-child(2) {
        position: absolute;
        margin: 24px 0 0 30px;
        font-size: 16px;
        color: #222222;
        font-weight: 600;
      }
    }

    .kan {
      position: absolute;
      margin: 30px 0 0 1106px;
      font-size: 12px;
      color: #666666;

      img {
        margin-left: 8px;
      }
    }

    .mokuai {
      position: absolute;
      top: 64px;
      left: 30px;
      width: 1140px;
      height: 204px;

      .one {
        width: 562px;
        height: 94px;
        border-radius: 8px;
        border: 1px solid #e5e5e5;
        position: relative;
        font-size: 16px;
        font-weight: 600;

        span:nth-child(1) {
          position: absolute;
          margin: 20px 0 0 20px;
          color: #222222;
        }

        span:nth-child(2) {
          position: absolute;
          margin: 22px 0 0 470px;
          color: #fe574a;
        }

        .biaosn {
          display: flex;
          margin: 54px 0 0 20px;

          .qians {
            text-align: center;
            line-height: 20px;
            width: 68px;
            height: 20px;
            background: #f8f8f8;
            border-radius: 2px;
            margin-left: 8px;
            font-size: 12px;
            color: #666;
          }

          .qians:nth-child(1) {
            margin-left: 0;
          }

          .position {
            padding: 2px 0 0 186px;
            font-size: 12px;
            color: #666666;
          }
        }
      }

      .one:nth-child(1) {
        float: left;
      }

      .one:nth-child(2) {
        float: right;
      }

      .one:nth-child(4) {
        margin-top: 16px;
        float: left;
      }

      .one:nth-child(5) {
        margin-top: 16px;
        float: right;
      }
    }
  }
}

.zhao-pin-zhi-wei {
  background-color: #fff;
  margin-top: 16px;
  width: 1200px;
  background: #ffffff;
  border-radius: 8px;
  backdrop-filter: blur(0px);
  box-sizing: border-box;
  padding: 30px;
  padding-left: 20px;
  // position: relative;

  .more-action {
    font-size: 12px;
    font-family:
      PingFangSC-Regular,
      PingFang SC;
    font-weight: 400;
    color: #666666;
    line-height: 12px;
    // position: absolute;
    top: 31px;
    right: 46px;
    cursor: pointer;
  }

  .title {
    @include title-box();
    margin-bottom: 20px;
  }

  .content {
    padding-left: 8px;

    ul {
      display: flex;
      flex-wrap: wrap;
      margin: -8px;

      li {
        margin: 8px;
      }
    }
  }
}
</style>
